package us.gaaoc.framework.util.validators;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;

public class NameValidator {
	
	private static final Logger LOG = Logger.getLogger(NameValidator.class);
	
	/**
	 * Constructor
	 * 
	 */
	public NameValidator() {

	}
	
	public boolean isFirstOrLastNameValid(String name){
		System.out.println("the name to validate is "+name);
		//Create the regular expression for the name
	    String patternStrForFirstOrLastName = "([a-zA-Z]*\\s*)*";
	    //Create the pattern on the basis of the expression
	    Pattern patternForFirstOrLastName = Pattern.compile(patternStrForFirstOrLastName);
	    String inputStrForFirstOrLasssstName = name;
	    //Match the input with pattern
	    Matcher matcherForFirstOrLastName = patternForFirstOrLastName.matcher(inputStrForFirstOrLasssstName);
	    boolean matchForFirstOrLastName = matcherForFirstOrLastName.matches(); 
	    System.out.println("the first name is "+name+" does it match the pattern? "+matchForFirstOrLastName);
		return matchForFirstOrLastName;
	}
	
	public boolean isMiddleNameValid(String name){
		System.out.println("the name to validate is "+name);
		//Create the regular expression for the middle name
	    String patternStrForMiddleName = "([a-zA-Z]*.?\\s*)*";
	    //Create the pattern on the basis of the expression
	    Pattern patternForMiddleName = Pattern.compile(patternStrForMiddleName);
	    String inputStrFormiddleName = name;
	    //Match the input with pattern
	    Matcher matcherForMiddleName = patternForMiddleName.matcher(inputStrFormiddleName);
	    boolean matchForMiddleName = matcherForMiddleName.matches(); 
	    System.out.println("the first name is "+name+" does it match the pattern? "+matchForMiddleName);
		return matchForMiddleName;
	}

}
